package day06;

import java.util.concurrent.TimeUnit;

/**
 * @author: 王丹
 * @create: 2021-06-30 22:19
 **/
public class Demo01 {
    public static void main(String[] args) throws InterruptedException {
        Thread thread = new Thread(new Runnable() {
            @Override
            public void run() {
                System.out.println("start");
                boolean b = true;
                //直接写成while(true)会报unreachable　statement标记为运行时错误
                while(b){

                }
                System.out.println("end");
            }
        });
        thread.start();
        TimeUnit.SECONDS.sleep(1);
        System.out.println("thread.getState() = " + thread.getState());
        //stop方法为何会被废弃而不推荐使用？stop方法过于暴力，强制把正在执行的方法停止了。
        thread.stop();
        TimeUnit.SECONDS.sleep(1);
        System.out.println("thread.getState()1 = " + thread.getState());

    }

}
